import { request } from '@vipl520/utils'
const path = '/' + import.meta.env.VITE_BASE_ADDON_NAME + '/addons.version/'

export function getList(page, size, search) {
  return request({
    url: path + 'index',
    method: 'get',
    params: { page, size, search, order: 'id desc' }
  })
}

// 删除
export function del(id) {
  return request({
    url: path + 'delete',
    method: 'post',
    data: { id }
  })
}

export function getForm(id, aid) {
  return request({
    url: path + 'getForm',
    method: 'post',
    data: { id, aid }
  })
}

export function getInstallSql(vid) {
  return request({
    url: path + 'getInstallSql',
    method: 'post',
    data: { vid }
  })
}

export function getUpgradeSql(vid) {
  return request({
    url: path + 'getUpgradeSql',
    method: 'post',
    data: { vid }
  })
}

export function updateInstallSql(vid) {
  return request({
    url: path + 'updateInstallSql',
    method: 'post',
    data: { vid }
  })
}

export function saveInstallSql(vid, sql) {
  return request({
    url: path + 'saveInstallSql',
    method: 'post',
    data: { vid, sql }
  })
}

export function comparisonSql(old_vid, new_vid) {
  return request({
    url: path + 'comparisonSql',
    method: 'post',
    data: { old_vid, new_vid }
  })
}

export function show(vid) {
  return request({
    url: path + 'show',
    method: 'post',
    data: { vid }
  })
}

export function pack(vid, formData) {
  return request({
    url: path + 'pack',
    method: 'post',
    data: { vid, formData }
  })
}

export function publish(vid, formData) {
  return request({
    url: path + 'publish',
    method: 'post',
    data: { vid, formData }
  })
}

export function getFiles(vid) {
  return request({
    url: path + 'getFiles',
    method: 'post',
    data: { vid }
  })
}

export function createEncrypt(vid, formData) {
  return request({
    url: path + 'createEncrypt',
    method: 'post',
    data: { vid, formData }
  })
}

export function mergeUpgradeSql(vid) {
  return request({
    url: path + 'mergeUpgradeSql',
    method: 'post',
    data: { vid }
  })
}

export function saveUpgradeSql(vid, sql) {
  return request({
    url: path + 'saveUpgradeSql',
    method: 'post',
    data: { vid, sql }
  })
}
